package tw.miku.protocol.codec.gold;

import java.nio.charset.CharacterCodingException;

import org.apache.mina.core.buffer.IoBuffer;

import tw.miku.constants.ProtocalConstants;
import tw.miku.protocol.codec.AbstractResponseMessagePack;

public class SetRoadCardResponsePack extends AbstractResponseMessagePack
{

	public int x;
	public int y;
	public int id;

	public long hostUserId;

	public boolean toggle;

	public SetRoadCardResponsePack()
	{
	}

	@Override
	public short getTag()
	{
		return ProtocalConstants.SET_ROAD_CARD;
	}

	@Override
	public IoBuffer encode() throws CharacterCodingException
	{
		IoBuffer buf = IoBuffer.allocate(21);
		buf.putUnsignedInt(17);
		buf.putShort(getTag());
		buf.putShort((short) 0);
		buf.putShort((short) x);
		buf.putShort((short) y);
		buf.putInt(id);
		buf.putUnsignedInt(hostUserId);
		buf.put((byte) (toggle ? 0 : 1));
		buf.position(0);

		return buf;
	}

}
